#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100005;
int n, m, a[N], c[N], T, x0[N], x1[N], x2[N], x3[N], R[N];
signed main()
{
    freopen("arena.in", "r", stdin);
    freopen("arena.out", "w", stdout);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> c[i];
    }
    int k;
    for (k = 0; pow(2, k) >= n; k++) {
        cin >> R[k];
    }
    cin >> T;
    for (int i = 0; i < T; i++) {
        cin >> x1[i] >> x2[i] >> x3[i] >> x4[i];
        cout << 1 << endl;
    }
    return 0;
}
